<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.3" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/avatar.jpg?v=5.1.3">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/avatar.jpg?v=5.1.3">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/avatar.jpg?v=5.1.3">


  <link rel="mask-icon" href="/images/avatar.jpg?v=5.1.3" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="学习 | 分享 | 交流 | 进步">
<meta property="og:type" content="website">
<meta property="og:title" content="Fighter&#39;s Blog">
<meta property="og:url" content="http://fighterhit.github.io/index.html">
<meta property="og:site_name" content="Fighter&#39;s Blog">
<meta property="og:description" content="学习 | 分享 | 交流 | 进步">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Fighter&#39;s Blog">
<meta name="twitter:description" content="学习 | 分享 | 交流 | 进步">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.3',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://fighterhit.github.io/"/>





  <title>Fighter's Blog</title><!-- hexo-inject:begin --><!-- hexo-inject:end -->
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Fighter's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">深度沉迷学习</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/12/04/other_notes/Kubernetes-记录/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/12/04/other_notes/Kubernetes-记录/" itemprop="url">Kubernetes 记录</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-12-04T11:17:30+08:00">
                2018-12-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/其它笔记/" itemprop="url" rel="index">
                    <span itemprop="name">其它笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="环境"><a href="#环境" class="headerlink" title="环境"></a>环境</h2><ul>
<li>7台虚拟机，三master三node，一台作为Docker私库</li>
<li>VIP<ul>
<li>192.168.11.222</li>
</ul>
</li>
<li>master<ul>
<li>192.168.11.31</li>
<li>192.168.11.32</li>
<li>192.168.11.33</li>
</ul>
</li>
<li>node<ul>
<li>192.168.11.34  </li>
<li>192.168.11.35</li>
<li>192.168.11.36</li>
</ul>
</li>
<li>Harbor registry<ul>
<li>192.168.11.200</li>
</ul>
</li>
</ul>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/12/04/other_notes/Kubernetes-记录/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/06/20/other_notes/制作Docker镜像/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/06/20/other_notes/制作Docker镜像/" itemprop="url">制作Docker镜像</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-06-20T16:11:54+08:00">
                2018-06-20
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/其它笔记/" itemprop="url" rel="index">
                    <span itemprop="name">其它笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>因为最近在做大数据分析大作业，要求将算法封装进 Docker ，因此临时学了一下 Docker 方面的知识，在这里简单记录一下。</p>
<h3 id="Docker-安装"><a href="#Docker-安装" class="headerlink" title="Docker 安装"></a>Docker 安装</h3><p>Docker 安装比较简单，可以参考网上<a href="http://www.runoob.com/docker/ubuntu-docker-install.html" target="_blank" rel="noopener">教程</a></p>
<h3 id="Docker-架构"><a href="#Docker-架构" class="headerlink" title="Docker 架构"></a>Docker 架构</h3><p>使用 Docker 前需要首先理解 Docker 的架构，因为以前自己只使用过 Vmware/VirtualBox 之类虚拟机，所以之前对 Docker 的理解也跟对 Vmware/VirtualBox 认识差不多，但学习之后发现他们还是有很大区别的， Docker 中融汇了面向对象的思想。网上有两张图对初学者很友好，让人很容易理解 Docker 架构思想：</p>
<img src="/2018/06/20/other_notes/制作Docker镜像/docker架构.png" title="Docker 架构">
<img src="/2018/06/20/other_notes/制作Docker镜像/docker架构图.png" title="Docker 架构">
<ul>
<li>Docker 使用客户端-服务器 (C/S) 架构模式，使用远程 API 来管理和创建 Docker 容器。</li>
<li>Docker 容器通过 Docker 镜像来创建。</li>
<li><strong>容器与镜像的关系类似于面向对象编程中的对象与类。</strong></li>
</ul>
<div class="table-container">
<table>
<thead>
<tr>
<th style="text-align:center">Docker</th>
<th style="text-align:center">面向对象</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">容器</td>
<td style="text-align:center">对象</td>
</tr>
<tr>
<td style="text-align:center">镜像</td>
<td style="text-align:center">类</td>
</tr>
</tbody>
</table>
</div>
<p>理解了上面几句话，大概就能跟我一样简单使用了，Docker hub 仓库其实就相当于打包了很多常用的 Docker 镜像，我们可以直接 pull 下来，启动成容器来在本地跑，省去了很多搭环境浪费的时间。</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/06/20/other_notes/制作Docker镜像/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/03/29/other_notes/使用VSCode搭建C-C-开发环境/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/03/29/other_notes/使用VSCode搭建C-C-开发环境/" itemprop="url">使用VSCode搭建C/C++开发环境</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-29T22:27:34+08:00">
                2018-03-29
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/其它笔记/" itemprop="url" rel="index">
                    <span itemprop="name">其它笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>本人虽然最近偏向Java语言，但平常有时也会遇到需要临时调试些C/C++代码，虽然电脑装了VS又感觉有点大材小用，而我平常一直是在用VSCode写markdown等，实际上VSCode和Sublime、Notepad++等都有很多插件可以装，装完就可以当作“短小精悍”的IDE啦，下面就记录下前天在Win10下用VSCode搭建C/C++环境的过程。</p>
<h2 id="环境"><a href="#环境" class="headerlink" title="环境"></a>环境</h2><ul>
<li>Windows 10 64位</li>
<li><a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode 1.21.1 64位</a></li>
<li><a href="http://www.mingw.org/" target="_blank" rel="noopener">MinGW</a></li>
</ul>
<h2 id="搭建过程"><a href="#搭建过程" class="headerlink" title="搭建过程"></a>搭建过程</h2><h3 id="安装C-C-插件"><a href="#安装C-C-插件" class="headerlink" title="安装C/C++插件"></a>安装C/C++插件</h3><p>在 VSCode 左侧第5个插件商店下面搜索<code>C/C++</code>，出现第一个插件应该就是微软官方插件，长这样：</p>
<img src="/2018/03/29/other_notes/使用VSCode搭建C-C-开发环境/C插件.png" title="C插件.png">
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/03/29/other_notes/使用VSCode搭建C-C-开发环境/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/03/26/algorithm_and_datastructure/Algorithms4/Ch4-Graph/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/03/26/algorithm_and_datastructure/Algorithms4/Ch4-Graph/" itemprop="url">（四）图</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-26T14:45:56+08:00">
                2018-03-26
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/算法与数据结构/" itemprop="url" rel="index">
                    <span itemprop="name">算法与数据结构</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="无向图"><a href="#无向图" class="headerlink" title="无向图"></a>无向图</h2><ul>
<li>图：是由一组顶点和一组能够将两个顶点相连的边组成的</li>
<li>自环：即可一条龙连接一个顶点和其自身的边</li>
<li>平行边：连接同一对顶点的两条边</li>
<li>常将含有平行边的图称为<strong>多重图</strong>，而没有平行边或自环的图称为<strong>简单图</strong></li>
<li>相邻：当两顶点通过一条边相连时，称这两个顶点是<strong>相邻</strong>的，并称连接<strong>依附于</strong>这两个顶点</li>
<li>度数：顶点的度数就是依附于它的边数</li>
<li>子图：由<strong>所有边的一个子集</strong>以及这些边<strong>依附的所有顶点</strong>组成的图</li>
<li>路径是由边顺序连接的一系列顶点；简单路径是一条没有重复顶点的路径</li>
<li>环是一条至少含有一条边且起点和终点相同的路径；简单环（除了起始和终点必须相同外）是一条不含有重复顶点和边的环</li>
<li>路径和环的长度为其中包含的边数</li>
<li>连通图：若从任意一个顶点都存在一条路径到达另一个任意顶点；非连通图：由若干连通部分组成，它们都是其极大连通子图</li>
<li><strong>树</strong>是无环连通图；互不相连的树组成的集合称为<strong>森林</strong>；<strong>连通图的生成树</strong>是它的一幅子图，它含有图中所有顶点且是一棵树；图的<strong>生成树森林</strong>是它的所有连通子图的生成树的集合</li>
<li>当且仅当V个结点的图G满足下列5个条件之一时是树<ul>
<li>G有V-1条边且不含环</li>
<li>G有V-1条边且是连通的</li>
<li>G是连通的，但删除任意一条边都会使它不再连通</li>
<li>G是无环图，但添加任意一条边都会产生一条环</li>
<li>G中任意一对顶点之间仅存在一条简单路径</li>
</ul>
</li>
<li><strong>二分图</strong>中每条边连接的两个顶点分别属于不同部分</li>
</ul>
<h3 id="图的数据结构"><a href="#图的数据结构" class="headerlink" title="图的数据结构"></a>图的数据结构</h3><img src="/2018/03/26/algorithm_and_datastructure/Algorithms4/Ch4-Graph/无向图API.png" title="无向图API">
<ol>
<li>必须为可能在应用中碰到的各种类型的图预留出足够<strong>空间</strong></li>
<li>Graph 实例方法的实现一定要快</li>
</ol>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/03/26/algorithm_and_datastructure/Algorithms4/Ch4-Graph/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/03/18/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch5-Java中的锁/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/03/18/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch5-Java中的锁/" itemprop="url">Java中的锁</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-18T22:47:23+08:00">
                2018-03-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java笔记/" itemprop="url" rel="index">
                    <span itemprop="name">Java笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <p>这部分主要介绍Java并发包中与锁相关的API和组件的使用和实现。</p>
<h2 id="Lock接口"><a href="#Lock接口" class="headerlink" title="Lock接口"></a>Lock接口</h2><p>Lock接口之前Java是靠synchronized关键字实现锁功能的，而Java SE 5后并发包中新增了Lock接口（以及相关实现类）用来实现锁功能，它提供了与synchronized关键字类似的同步功能，只是在使用时需要显式地获取和释放锁。虽没有了隐式释放锁的便利性，但有了如下优点：</p>
<ol>
<li>锁获取与释放的可操作性</li>
<li>可中断的获取锁</li>
<li>超时获取锁等</li>
</ol>
<p>Lock使用方式：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">Lock lock = <span class="keyword">new</span> ReentrantLock();</div><div class="line">lock.lock();</div><div class="line"><span class="keyword">try</span> &#123;</div><div class="line">&#125; <span class="keyword">finally</span> &#123;</div><div class="line">    lock.unlock();</div><div class="line">&#125;</div></pre></td></tr></table></figure>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/03/18/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch5-Java中的锁/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/03/14/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch4-Java并发编程基础/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/03/14/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch4-Java并发编程基础/" itemprop="url">（四）Java并发编程基础</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-14T15:18:28+08:00">
                2018-03-14
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java笔记/" itemprop="url" rel="index">
                    <span itemprop="name">Java笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="线程简介"><a href="#线程简介" class="headerlink" title="线程简介"></a>线程简介</h2><p>现代操作系统调度的最小单元是线程，也叫轻量级进程（LightWeight Process），在一个进程里可以创建多个线程，这些线程都拥有各自的计数器、堆栈和局部变量等属性，并且能够访问共享的内存变量。处理器在这些线程上高速切换，让使用者感觉到这些线程在同时执行。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MultiThread</span> </span>&#123;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</div><div class="line">        <span class="comment">// 获取Java线程管理MXBean</span></div><div class="line">        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();</div><div class="line">        <span class="comment">// 不需要获取同步的monitor和synchronizer信息，仅获取线程和线程堆栈信息</span></div><div class="line">        ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(<span class="keyword">false</span>, <span class="keyword">false</span>);</div><div class="line">        <span class="comment">// 遍历线程信息，仅打印线程ID和线程名称信息</span></div><div class="line">        <span class="keyword">for</span> (ThreadInfo threadInfo : threadInfos) &#123;</div><div class="line">            System.out.println(<span class="string">"["</span> + threadInfo.getThreadId() + <span class="string">"] "</span> + threadInfo.getThreadName());</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"><span class="comment">//输出</span></div><div class="line">[<span class="number">6</span>] Monitor Ctrl-Break</div><div class="line">[<span class="number">5</span>] Attach Listener</div><div class="line">[<span class="number">4</span>] Signal Dispatcher</div><div class="line">[<span class="number">3</span>] Finalizer</div><div class="line">[<span class="number">2</span>] Reference Handler</div><div class="line">[<span class="number">1</span>] main</div></pre></td></tr></table></figure>
<h3 id="为什么使用线程"><a href="#为什么使用线程" class="headerlink" title="为什么使用线程"></a>为什么使用线程</h3><ol>
<li>更多处理器核心</li>
<li>更快响应时间</li>
<li>更好的编程模型
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/03/14/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch4-Java并发编程基础/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/03/04/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch3-Java内存模型/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/03/04/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch3-Java内存模型/" itemprop="url">（三）Java内存模型</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-04T14:28:35+08:00">
                2018-03-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java笔记/" itemprop="url" rel="index">
                    <span itemprop="name">Java笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="Java-内存模型的基础"><a href="#Java-内存模型的基础" class="headerlink" title="Java 内存模型的基础"></a>Java 内存模型的基础</h2><h3 id="并发编程模型的两个关键问题"><a href="#并发编程模型的两个关键问题" class="headerlink" title="并发编程模型的两个关键问题"></a>并发编程模型的两个关键问题</h3><ol>
<li>线程之间如何<strong>通信</strong>（线程之间以何种机制来<strong>交换信息</strong>）</li>
<li>线程之间如何<strong>同步</strong>（程序中用于<strong>控制不同线程间操作发生相对顺序的机制</strong>）</li>
</ol>
<p>在命令式编程中，线程之间通信机制有两种：共享内存和消息传递。</p>
<ol>
<li>共享内存的并发模型<ul>
<li>线程通信：线程之间共享程序的公共状态，<strong>通过写-读内存中的公共状态进行隐式通信</strong></li>
<li>线程同步：<strong>同步是显式进行的。</strong>程序员必须显式指定某个方法或某段代码需要在线程之间互斥执行。</li>
</ul>
</li>
<li>消息传递的并发模型<ul>
<li>线程通信：线程之间没有公共状态，线程间<strong>必须通过发送消息来显式进行通信</strong></li>
<li>线程同步：由于消息的发送必须在消息的接收之前，因此<strong>同步是隐式进行的。</strong></li>
</ul>
</li>
</ol>
<p><strong>Java 并发采用共享内存模型，Java 线程间通信总是隐式进行，整个通信过程对程序员完全透明。</strong><br>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/03/04/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch3-Java内存模型/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/03/02/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch2-Java并发机制的底层实现原理/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/03/02/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch2-Java并发机制的底层实现原理/" itemprop="url">（二）Java并发机制的底层实现原理</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-02T13:16:10+08:00">
                2018-03-02
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java笔记/" itemprop="url" rel="index">
                    <span itemprop="name">Java笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <p>Java代码在编译后会变成Java字节码，字节码被类加载器加载到JVM里，JVM执行字节码，最终需要转化为汇编指令在CPU上执行，Java中所使用的并发机制依赖于JVM的实现和CPU的指令。</p>
<h2 id="volatile-应用"><a href="#volatile-应用" class="headerlink" title="volatile 应用"></a>volatile 应用</h2><p><strong>volatile 是轻量级 synchronized</strong>，它在多处理器开发中保证了共享变量的“可见性”。</p>
<blockquote>
<p>可见性：当一个线程修改一个共享变量时，另外一个线程能读到这个修改后的值。</p>
</blockquote>
<p>若 volatile 变量修饰符使用恰当，它<strong>比 synchronized 使用和执行成本更低</strong>，因为它<strong>不会引起线程上下文切换和调度。</strong></p>
<h3 id="volatile-定义与实现原理"><a href="#volatile-定义与实现原理" class="headerlink" title="volatile 定义与实现原理"></a>volatile 定义与实现原理</h3><blockquote>
<p>Java 语言规范对 volatile 的定义：Java 编程语言允许线程访问共享变量，为了确保共享变量能被准确和一致地更新，线程应确保通过排它锁单独获得这个变量。Java 语言提供了 volatile，在某些情况下比锁更加厉害。<strong>若一个字段被声明为 volatile，Java 线程内存模型确保所有线程看到这个变量的值是一致的。</strong><br>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/03/02/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch2-Java并发机制的底层实现原理/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/03/02/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch1-并发编程的挑战/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/03/02/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch1-并发编程的挑战/" itemprop="url">（一）并发编程的挑战</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-03-02T12:12:44+08:00">
                2018-03-02
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java笔记/" itemprop="url" rel="index">
                    <span itemprop="name">Java笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="上下文切换"><a href="#上下文切换" class="headerlink" title="上下文切换"></a>上下文切换</h2><p>单核处理器也支持多线程执行代码，CPU通过给每个线程分配CPU时间片来实现这个机制。时间片是CPU分配给各个线程的时间，因为时间片非常短，所以CPU通过不停地切换线程执行，让我们感觉多个线程是同时执行的，时间片一般是几十毫秒（ms）。</p>
<blockquote>
<p>上下文切换：<strong>任务从保存到再加载</strong>的过程就是一次上下文切换。</p>
</blockquote>
<h3 id="多线程一定快吗？"><a href="#多线程一定快吗？" class="headerlink" title="多线程一定快吗？"></a>多线程一定快吗？</h3><p>不一定，因为线程有创建和上下文切换开销。</p>
<h3 id="减少上下文切换"><a href="#减少上下文切换" class="headerlink" title="减少上下文切换"></a>减少上下文切换</h3><p>方法：</p>
<ul>
<li>无锁并发编程<br>  多线程竞争锁时，会引起上下文切换，所以多线程处理数据时，可以用一些方法来避免使用锁，如将数据的 ID 按 Hash 算法取模分段，不同线程处理不同段数据。</li>
<li>CAS 算法<br>  Java 的 Atomic 包使用 CAS 算法来更新数据，而不需要加锁。</li>
<li>使用最少线程和使用协程<ul>
<li>避免创建不需要的线程，比如任务很少，但创建了很多线程来处理，这会造成大量线程都处于等待状态</li>
<li>协程：在单线程里实现多任务的调度，并在单线程里维持多任务间的切换
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2018/03/02/Java_Notes/JavaConcurrence/TheArtOfJavaConcurrency/Ch1-并发编程的挑战/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://fighterhit.github.io/2018/02/24/Java_Notes/Jvm/类加载/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fighter.">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Fighter's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/02/24/Java_Notes/Jvm/类加载/" itemprop="url">类加载</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-02-24T16:58:42+08:00">
                2018-02-24
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java笔记/" itemprop="url" rel="index">
                    <span itemprop="name">Java笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="类加载机制"><a href="#类加载机制" class="headerlink" title="类加载机制"></a>类加载机制</h2><h3 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h3><ul>
<li>虚拟机把描述类的数据从 class 文件加载到内存，并对数据进行校验，解析和初始化，最终形成可以被虚拟机直接使用的 java 类型，这就是虚拟机的类加载机制。</li>
<li>懒加载</li>
</ul>
<h3 id="类加载时机"><a href="#类加载时机" class="headerlink" title="类加载时机"></a>类加载时机</h3><img src="/2018/02/24/Java_Notes/Jvm/类加载/类加载时机.png" title="类加载时机">
<h4 id="初始化"><a href="#初始化" class="headerlink" title="初始化"></a>初始化</h4><ol>
<li>遇到 <code>new、getstatic、putstatic 或 invokestatic</code> 这 4 条字节码指令时，如果类没有进行初始化，则需要先触发其初始化。生成这 4 条指令的最常见的 Java 代码场景是：使用 new 关键字实例化对象的时候、读取或设置一个类的静态字段（被 final 修饰、已在编译器把结果放入常量池的静态字段除外）的时候，</li>
<li>使用 Java.lang.refect 包的方法对类进行反射调用时，如果类还没有进行过初始化，则需要先触发其初始化。</li>
<li>当初始化一个类的时候，如果发现其父类还没有进行初始化，则需要先触发其父类的初始化。</li>
<li>当虚拟机启动时，用户需要指定一个要执行的主类（包含 main() 方法的那个类），虚拟机会先执行该主类。</li>
</ol>
<h4 id="不被初始化的例子"><a href="#不被初始化的例子" class="headerlink" title="不被初始化的例子"></a>不被初始化的例子</h4><ul>
<li>通过子类引用父类的静态字段，子类不会被初始化</li>
<li>通过数组定义来引用类</li>
<li>调用类的常量</li>
</ul>
<h3 id="类加载的过程"><a href="#类加载的过程" class="headerlink" title="类加载的过程"></a>类加载的过程</h3><img src="/2018/02/24/Java_Notes/Jvm/类加载/类加载的过程.png" title="类加载的过程">
<h4 id="加载"><a href="#加载" class="headerlink" title="加载"></a>加载</h4><ul>
<li>通过一个类的全限定名来获取定义此类的二进制流</li>
<li>将这个字节流所代表的静态存储结构转化为方法区的运行时数据结构</li>
<li>在内存中生成一个代表这个类的 class 对象，作为这个类的各种数据的访问入口</li>
</ul>
<h5 id="加载源"><a href="#加载源" class="headerlink" title="加载源"></a>加载源</h5><ul>
<li>文件<ul>
<li>class 文件</li>
<li>jar 文件</li>
</ul>
</li>
<li>网络</li>
<li>计算生成一个二进制流<ul>
<li>$Proxy</li>
</ul>
</li>
<li>由其它文件生成<ul>
<li>jsp</li>
</ul>
</li>
<li>数据库</li>
</ul>
<h4 id="验证"><a href="#验证" class="headerlink" title="验证"></a>验证</h4><img src="/2018/02/24/Java_Notes/Jvm/类加载/类加载的过程.png" title="类加载的过程">
<ul>
<li>验证是连接的第一步，这一阶段的目的是为了确保 class 文件的字节流中包含的信息符合当前虚拟机的要求。并且不会危害虚拟机自身的安全。</li>
<li>文件格式验证</li>
<li>元数据验证</li>
<li>字节码验证</li>
<li>符号引用验证</li>
</ul>
<h4 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h4><ul>
<li>准备阶段正式为<strong>类变量</strong>分配内存并设置<strong>变量的默认值</strong>。这些变量使用的内存都将在方法区进行分配。如果变量被 final 修饰，则在这个过程中，常量值会被一同指定。</li>
</ul>
<h4 id="解析"><a href="#解析" class="headerlink" title="解析"></a>解析</h4><ul>
<li>解析阶段是虚拟机将常量池中的符号引用替换为直接引用的过程。</li>
<li>类或者接口的解析</li>
<li>字段解析</li>
<li>类方法解析</li>
<li>接口方法解析</li>
</ul>
<p><a href="http://blog.csdn.net/u011080472/article/details/51329315" target="_blank" rel="noopener">【深入理解JVM】：类加载机制</a></p>
<h4 id="初始化-1"><a href="#初始化-1" class="headerlink" title="初始化"></a>初始化</h4><ul>
<li>初始化是类加载的最后一步</li>
<li>初始化是执行 <code>&lt;clinit&gt;()</code> 方法的过程<blockquote>
<p>类初始化阶段是类加载过程的最后一步，前面的类加载过程中，除了在加载阶段用户应用程序可以通过自定义类加载器参与之外，其余动作完全由虚拟机主导和控制。到了初始化阶段，才真正开始执行类中定义的Java程序代码（或者说是字节码）。<br>在准备阶段，变量已经赋过一次系统要求的初始值，而在初始化阶段，则根据程序员通过程序制定的主观计划去初始化类变量和其他资源，或者可以从另外一个角度来表达：初始化阶段是执行类构造器<clinit()>方法的过程。<br><a href="http://blog.csdn.net/u011080472/article/details/51329315" target="_blank" rel="noopener">【深入理解JVM】：类加载机制</a><br><a href="http://www.importnew.com/18548.html" target="_blank" rel="noopener">Java虚拟机类加载机制</a><br><a href="http://blog.csdn.net/qq_20176495/article/details/74936554" target="_blank" rel="noopener">类加载机制</a><br><a href="http://blog.csdn.net/zjkc050818/article/details/78376195" target="_blank" rel="noopener">【Java面试题】之类加载：从面试题分析Java类加载机制</a></clinit()></p>
</blockquote>
</li>
</ul>
<h3 id="类加载器"><a href="#类加载器" class="headerlink" title="类加载器"></a>类加载器</h3><ul>
<li>虚拟机的设计团队把类加载阶段中的“通过一个类的全限定名来获取描述此类的二进制字节流”这个动作放到 Java 虚拟机外部去实现，以便让应用程序自己决定如何去获取所需要的类。实现这个动作的代码模块称之为类加载器。</li>
<li>只有被同一个类加载器加载的类才可能会相等。相同的字节码被不同的类加载器加载的类不相等。</li>
</ul>
<h4 id="类加载器分类"><a href="#类加载器分类" class="headerlink" title="类加载器分类"></a>类加载器分类</h4><ul>
<li>启动类加载器<ul>
<li>由 C++ 实现，是虚拟机的一部分，用于加载 javahome 下的 lib 目录下的类</li>
</ul>
</li>
<li>扩展类加载器<ul>
<li>加载 javahome 下 /lib/ext 目录中的类</li>
</ul>
</li>
<li>应用程序类加载器<ul>
<li>加载用户类路径上的所指定的类库</li>
</ul>
</li>
<li>自定义类加载器<ul>
<li>定义一个类，继承 classloader</li>
<li>重写 loadclass 方法</li>
<li>实例化 class 对象</li>
</ul>
</li>
</ul>
<h4 id="自定义类加载器的优势"><a href="#自定义类加载器的优势" class="headerlink" title="自定义类加载器的优势"></a>自定义类加载器的优势</h4><ul>
<li>类加载器是 Java 语言的一项创新，也是 Java 语言流行的重要原因之一，它最初的设计是为了满足 Java Applet 的需求而开发。</li>
<li>高度灵活性</li>
<li>通过自定义类加载器可以实现热部署</li>
<li>代码加密</li>
</ul>
<h4 id="双亲委派模型"><a href="#双亲委派模型" class="headerlink" title="双亲委派模型"></a>双亲委派模型</h4><img src="/2018/02/24/Java_Notes/Jvm/类加载/类加载器.png" title="类加载器">
<ul>
<li>从 jdk1.2 开始，java 虚拟机规范推荐开发者使用双亲委派模型（ParentsDelegation Model）进行类加载，其加载过程如下：</li>
<li>如果一个类加载器收到了类加载请求，它首先不会自己去尝试加载这个类，而是把类加载请求委派给父类加载器去完成</li>
<li>每一层的类加载器都把类加载请求委派给父类加载器，直到所有的类加载请求都应该传递给顶层的启动类加载器</li>
<li>如果顶层的启动类加载器无法完成加载请求，子类加载器尝试去加载，如果连最初发起类加载请求的类加载器也无法完成加载请求时，将会抛出 ClassNotFoundException，而不再调用其子类加载器去进行类加载。</li>
<li>双亲委派模型的类加载机制的优点是 java 类 它的类加载器一起具备了一种带优先级的层次关系，越是基础的类，越是被上层的类加载器进行加载，保证了 java 程序的稳定运行。</li>
</ul>
<h3 id="虚拟机字节码执行引擎"><a href="#虚拟机字节码执行引擎" class="headerlink" title="虚拟机字节码执行引擎"></a>虚拟机字节码执行引擎</h3><ul>
<li>字节码结构</li>
<li>类加载</li>
<li>虚拟机字节码执行引擎</li>
</ul>
<h4 id="运行时栈帧结构"><a href="#运行时栈帧结构" class="headerlink" title="运行时栈帧结构"></a>运行时栈帧结构</h4><ul>
<li>局部变量表</li>
<li>操作数栈</li>
<li>动态链接</li>
<li>方法返回地址</li>
<li>附加信息</li>
</ul>
<p><a href="http://blog.csdn.net/sinat_33087001/article/details/77200623" target="_blank" rel="noopener">[深入理解JVM 六]—-虚拟机字节码执行系统</a><br><a href="http://blog.csdn.net/rusbme/article/details/51217620" target="_blank" rel="noopener">Java方法执行</a><br><a href="http://blog.csdn.net/ns_code/article/details/17965867" target="_blank" rel="noopener">【深入Java虚拟机】之五：多态性实现机制——静态分派与动态分派</a></p>
<h5 id="局部变量表"><a href="#局部变量表" class="headerlink" title="局部变量表"></a>局部变量表</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="comment">//实例变量有默认值，即便不赋值也可以直接使用</span></div><div class="line"><span class="keyword">private</span> <span class="keyword">int</span> a;</div><div class="line"><span class="keyword">private</span> <span class="keyword">int</span> b;</div><div class="line"></div><div class="line">add()&#123;</div><div class="line">    <span class="keyword">int</span> a, b;</div><div class="line">    <span class="keyword">return</span> a + b;<span class="comment">//没有赋值，报错</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li>slot 32 64</li>
<li>byte、boolean、short、char、int、float、double、long（不会出现线程安全性问题）、reference（指向对象地址）、returnAddress（不再使用）</li>
</ul>
<blockquote>
<p>线程安全性问题三要素：</p>
<ol>
<li>多线程</li>
<li>要有共享资源</li>
<li>对共享资源进行非原子性操作</li>
</ol>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">int</span> a = <span class="number">10</span>;</div><div class="line">a--;<span class="comment">// a = a - 1;</span></div></pre></td></tr></table></figure>
<ul>
<li>slot 复用：当一个变量的 pc 寄存器的值大于 slot 的作用域的时候，slot 是可以复用的</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span></span>&#123;</div><div class="line">    <span class="keyword">byte</span>[] buff = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">60</span> * <span class="number">1024</span> * <span class="number">1024</span>];</div><div class="line">    System.gc();<span class="comment">//不回收</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span></span>&#123;</div><div class="line">    &#123;</div><div class="line">        <span class="keyword">byte</span>[] buff = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">60</span> * <span class="number">1024</span> * <span class="number">1024</span>];</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">int</span> a = <span class="number">10</span>;<span class="comment">//对局部变量表读写了</span></div><div class="line">    System.gc();<span class="comment">//回收，因此引用使用完使其为 null，方便垃圾回收</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p><a href="https://www.jianshu.com/p/a474dd20b08d" target="_blank" rel="noopener">局部变量表Slot复用</a></p>
<h5 id="操作数栈"><a href="#操作数栈" class="headerlink" title="操作数栈"></a>操作数栈</h5><p>每个栈帧不完全独立，实际上局部变量表的部分数据重叠<br><a href="http://blog.csdn.net/a616413086/article/details/51272309" target="_blank" rel="noopener">栈帧、局部变量表、操作数栈</a></p>
<h5 id="动态连接"><a href="#动态连接" class="headerlink" title="动态连接"></a>动态连接</h5><h5 id="方法返回地址和附加信息"><a href="#方法返回地址和附加信息" class="headerlink" title="方法返回地址和附加信息"></a>方法返回地址和附加信息</h5><ul>
<li>方法返回地址：调用时通过一个指向方法的指针指向方法的地址，方法返回时将回归到调用处，那个地方是返回地址。</li>
<li>附加信息：虚拟机规范中允许具体的虚拟机实现增加一些规范里没有描述的信息到栈帧中。这部分信息完全取决于虚拟机的实现。</li>
</ul>
<h3 id="方法调用"><a href="#方法调用" class="headerlink" title="方法调用"></a>方法调用</h3><ul>
<li>解析调用</li>
<li>分派调用<ul>
<li>静态分派调用</li>
<li>动态分派调用</li>
</ul>
</li>
<li><p>动态语言支持</p>
</li>
<li><p>方法调用并不等同于方法的执行，方法调用阶段的唯一任务就是<strong>确定被调用方法的版本</strong></p>
</li>
<li>封装、继承、多态</li>
</ul>
<blockquote>
<p>类加载过程中的解析作用：将 class 文件中的符号引用解析成直接引用</p>
</blockquote>
<h4 id="解析调用"><a href="#解析调用" class="headerlink" title="解析调用"></a>解析调用</h4><p>静态方法、构造器方法、私有方法和被 final 修饰的方法不能被重写、重载，编译完就能确定版本</p>
<ul>
<li>invokestatic（静态方法的字节码）</li>
<li>invokespecial（构造器方法、私有方法、父类方法生成的字节码）</li>
<li>invokevirtual</li>
<li>invokeinterface</li>
<li>invokedynamic</li>
</ul>
<h4 id="静态分派调用（单、多分派）"><a href="#静态分派调用（单、多分派）" class="headerlink" title="静态分派调用（单、多分派）"></a>静态分派调用（单、多分派）</h4><p>静态分派调用主要针对方法的重载（编译期确定？）：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">StaticCall</span> </span>&#123;</div><div class="line">    <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">Parent</span> </span>&#123;</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">Child1</span> <span class="keyword">extends</span> <span class="title">Parent</span></span>&#123;&#125;</div><div class="line">    <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">Child2</span> <span class="keyword">extends</span> <span class="title">Parent</span></span>&#123;&#125;</div><div class="line"></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(Child1 c1)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"c1 is called"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(Child2 c2)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"c2 is called"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(Parent p)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"p is called"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</div><div class="line">        <span class="comment">//=左边静态类型 右边实际类型</span></div><div class="line">        Parent p1 = <span class="keyword">new</span> Child1();</div><div class="line">        Parent p2 = <span class="keyword">new</span> Child2();</div><div class="line">        StaticCall s = <span class="keyword">new</span> StaticCall();</div><div class="line">        s.sayHello(p1);</div><div class="line">        s.sayHello(p2);</div><div class="line">        <span class="comment">//实际类型发生改变</span></div><div class="line">        Parent p = <span class="keyword">new</span> Child1();</div><div class="line">        p = <span class="keyword">new</span> Child2();</div><div class="line">        <span class="comment">//静态类型发生改变</span></div><div class="line">        s.sayHello((Child2)p);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>方法调用时会选一个最先匹配的执行：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">StaticCallTest2</span> </span>&#123;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(<span class="keyword">byte</span> a)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"byte"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(<span class="keyword">short</span> a)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"short"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(<span class="keyword">int</span> a)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"int"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(<span class="keyword">long</span> a)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"long"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(<span class="keyword">char</span> a)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"char"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(Character a)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"Character"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(Object a)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"Object"</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">sayHello</span><span class="params">(<span class="keyword">char</span> ... a)</span></span>&#123;</div><div class="line">        System.out.println(<span class="string">"char ..."</span>);</div><div class="line">    &#125;</div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</div><div class="line">        StaticCallTest2 s = <span class="keyword">new</span> StaticCallTest2();</div><div class="line">        s.sayHello(<span class="string">'1'</span>);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h4 id="动态分派调用（单、多分派）"><a href="#动态分派调用（单、多分派）" class="headerlink" title="动态分派调用（单、多分派）"></a>动态分派调用（单、多分派）</h4><p>动态分派调用针对方法的重写：</p>
<ul>
<li>找到操作数栈顶的第一个元素所指向的对象的<strong>实际类型</strong></li>
<li>如果在实际类型中找到与常量池中的描述符和简单名称都相符的方法，则进行访问权限校验，如果通过则直接返回这个方法的直接引用，查找过程结束，如果不通过，抛出异常</li>
<li>按照继承关系从下往上依次对实际类型的各父类（父类编译期就可知道）进行搜索与验证</li>
<li>如果始终没有找到，则抛出 AbstractMethodError</li>
</ul>
<h3 id="动态类型语言支持"><a href="#动态类型语言支持" class="headerlink" title="动态类型语言支持"></a>动态类型语言支持</h3><ul>
<li>静态类型的语言在非运行阶段，变量的类型是可以确定的，也就是说变量是有类型的</li>
<li>动态类型语言在非运行阶段，变量的类型是无法确定的，也就是变量是没有类型的，但是值是有类型的，也就是运行期间可以确定变量的值的类型</li>
</ul>
<h3 id="字节码执行引擎小结"><a href="#字节码执行引擎小结" class="headerlink" title="字节码执行引擎小结"></a>字节码执行引擎小结</h3><ul>
<li>代码执行时涉及的内存结构</li>
<li>如何找到正确的执行方法</li>
<li>如何执行方法的字节码</li>
</ul>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><ul>
<li>Java 技术体系<ul>
<li>Java 程序设计语言</li>
<li><strong>Java 虚拟机</strong></li>
<li><strong>class 文件格式</strong></li>
<li>Java API</li>
<li>第三方类库</li>
</ul>
</li>
</ul>
<hr>
<ul>
<li>Java 技术体系，认识 Java 虚拟机</li>
<li>内存管理<ul>
<li>运行时内存区域</li>
<li>对象的创建，内存布局以及访问定位</li>
<li>垃圾回收<ul>
<li>判断对象是否存活算法</li>
<li>垃圾收集算法</li>
<li>垃圾收集器</li>
</ul>
</li>
<li>内存的分配</li>
<li>Java 的监控工具</li>
</ul>
</li>
<li>Java 虚拟机的运行<ul>
<li>class 文件格式</li>
<li>class 字节码指令</li>
<li>类加载</li>
<li>字节码执行引擎</li>
</ul>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.jpg"
                alt="Fighter." />
            
              <p class="site-author-name" itemprop="name">Fighter.</p>
              <p class="site-description motion-element" itemprop="description">学习 | 分享 | 交流 | 进步</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">26</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">28</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          <div class="links-of-author motion-element">
            
              
                <span class="links-of-author-item">
                  <a href="https://github.com/fighterhit" target="_blank" title="GitHub">
                    
                      <i class="fa fa-fw fa-github"></i>GitHub</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://weibo.com/fighterhit" target="_blank" title="Weibo">
                    
                      <i class="fa fa-fw fa-weibo"></i>Weibo</a>
                </span>
              
            
          </div>

          
          

          
          

          

        </div>
      </section>

      

      
      
    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2016 - <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-home"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Fighter.</span>

  
</div>









        
<div class="busuanzi-count">
  <!--<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>-->
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  

    <span class="site-pv">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
    Hosted by <a target="_blank" href="https://github.com/">GitHub Pages</a>
    </span>

</div>







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.3"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.3"></script>



  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.3"></script>



  


  




	





  





  








  





  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script><!-- hexo-inject:begin --><!-- hexo-inject:end -->
  


  

  

</body>
</html>
